<?php
include("include/config.inc.php");
if(isset($_REQUEST['item']))
{
  $itemId=$_REQUEST['item'];
  $selectIceCream="SELECT itemName,itemPrice FROM item WHERE itemId='$itemId'";
  $iceCreamRes=mysql_query($selectIceCream);
  $iceCreamRow=mysql_fetch_array($iceCreamRes);
  $itemName=$iceCreamRow['itemName'];
  $itemPrice=$iceCreamRow['itemPrice'];
}
else
{
  $itemName="";
  $itemPrice="";
}


if(isset($_REQUEST['waiter']))
  {
    $waiterVar = $_REQUEST['waiter'] ;
  }
  else
  {
    $waiterVar = 0 ;
  }
  
  if(isset($_REQUEST['table']))
  {
    $tableVar = $_REQUEST['table'] ;
  }
  else
  {
    $tableVar = 0 ;
  }
  if(isset($_REQUEST['tablePart']))
  {
    $tablePartVar = $_REQUEST['tablePart'] ;
  }
  else
  {
    $tablePartVar = 'A' ;
  }
  if($waiterVar==0 and $tableVar==0 )
  {
  	echo"<script>alert('please select table and waiter');</script>";
  	header("location:index.php");
  }
  $k = 0;
  $updateItem = array();
  $selectItemQuantity="SELECT ordereditems.itemId,ordereditems.quantity
                         FROM ordereditems 
                        INNER JOIN ordermaster 
                        WHERE waiterId='".$_REQUEST['waiter']."' 
                          AND tableId='".$_REQUEST['table']."'
                          AND orderstatus = 'L'";
  $selectItemQuantityRes=mysql_query($selectItemQuantity);
  while($itemRows=mysql_fetch_array($selectItemQuantityRes))
  {
    $updateItem['itemId'][$k]   = $itemRows['itemId'];
    $updateItem['quantity'][$k] = $itemRows['quantity'];
    $k++;
  }
  

include("./bottom.php");
$smarty->assign('itemPrice', $itemPrice);
$smarty->assign('itemName', $itemName);
$smarty->assign('tableVar', $tableVar);
$smarty->assign('waiterVar', $waiterVar);
$smarty->assign('tablePartVar', $tablePartVar);
$smarty->assign('updateItem', $updateItem);
$smarty->display('iceCream.tpl');
?>